#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
const int MOD = 1e9+7;
int jc[N];
int jc_1[N];
int qpow(int x,int p){
    int res = 1;
    while(p){
        if(p & 1){
            res = 1ll*res*x%MOD;
        }
        x = 1ll*x*x%MOD;
        p >>= 1;
    }
    return res;
}
int f1[N];
int C(int n,int m){
    return 1ll*jc[n] * jc_1[n - m]%MOD*jc_1[m]%MOD;
}
int ftot[N];
int p[N];
int pinv[N];
int main(){
    freopen("permutation.in","r",stdin);
    freopen("permutation.out","w",stdout);
    int n,m;
    cin>>n>>m;
    jc[0] = 1;
    jc_1[0] = 1;
    p[0] = 1;
    pinv[0] = 1;
    int inv2 = (MOD + 1)/2;
    for(int i = 1;i<=2*n;i++){
        jc[i] = 1ll*jc[i - 1]*i%MOD;
        p[i] = p[i - 1]*2ll%MOD;
        pinv[i] = 1ll*pinv[i - 1]*inv2%MOD;
    }
    jc_1[2*n] = qpow(jc[n * 2],MOD - 2);
    for(int i = 2*n - 1;i >= 1;i--){
        jc_1[i] = 1ll*jc_1[i + 1]*(i + 1)%MOD;
    }
    // part1
    int tcnt = 0;
    ftot[0] = 1;
    if((n*2) % m != 0){
        int vl1 = (n*2)/m + 1;
        tcnt += vl1/2;
        f1[0] = 1;
        for(int i = 1;i<=tcnt;i++){
            f1[i] = 1ll*jc[vl1]*pinv[i]%MOD*jc_1[vl1 - 2*i]%MOD*jc_1[i]%MOD;
        }
        for(int i = 1;i <= ((n*2)%m);i++){
            for(int k = tcnt*i;k >= 1;k--){
                for(int j = 1;j <= min(k,tcnt);j++){
                    ftot[k] = (ftot[k] + 1ll*ftot[k - j]*f1[j]%MOD)%MOD;
                }
            }
        }
        tcnt *= (n*2)%m;
        memset(f1,0,sizeof(f1));
    }
    int vl = (n*2)/m;
    int t1 = vl/2;
    for(int i = 1;i<=t1;i++){
        f1[i] = 1ll*jc[vl]*pinv[i]%MOD*jc_1[vl - 2*i]%MOD*jc_1[i]%MOD;
    }
    for(int i = 1;i <= (m - (n*2)%m);i++){
        for(int k = tcnt + i*t1;k >= 1;k--){
            for(int j = 1;j <= min(k,t1);j++){
                ftot[k] = (ftot[k] + 1ll*ftot[k - j]*f1[j]%MOD)%MOD;
            }
        }
    }
    tcnt += t1*(m - n%m);
    int ans = 0;
    for(int i = 0;i <= n;i++){
        if(i % 2){
            ans = (ans + MOD - 1ll*C(n,i)*jc[i]%MOD*jc[2*(n - i)]%MOD*ftot[i]%MOD*p[i]%MOD)%MOD;
        }else{
            ans = (ans + 1ll*C(n,i)*jc[i]%MOD*jc[2*(n - i)]%MOD*ftot[i]%MOD*p[i]%MOD)%MOD;
        }
    }
    cout<<ans<<'\n';
}